@echo off
cd /d %~dp0
chcp 65001	
setlocal enabledelayedexpansion
set file_name=prj_date
set file=%file_name%.h
set file_tmp=%file_name%_tmp.h
set file_bak=%file_name%_bak.h
for %%i in ("%file%") do (
    set file_path=%%~fi
)
for %%i in ("%file_tmp%") do (
    set file_temp_path=%%~fi
)
for %%i in ("%file_bak%") do (
    set file_bak_path=%%~fi
)

set error_str=#error please_use_auto_pre_compile
set yy=%date:~5,2%
set mm=%date:~8,2%
set dd=%date:~11,2%
set "today_str=#define FW_STRING_DATE "%yy%%mm%%dd%""
for /f "delims=" %%i in ('type "%file_path%"') do (             				
    set str=%%i
    set "str_test=!str: =!"    
    if not !str_test!.==. (    			
		    if !str! NEQ !today_str!	(	
				del %file_temp_path%	    	
		    	echo %today_str%>>%file_temp_path%
				copy "%file_path%" "%file_bak_path%" >nul 2>nul
                move "%file_temp_path%" "%file_path%"
		    )		    		    
    )    
    
)

